﻿using System.Linq;
using System.Security.Principal;
using pbvs.Models;

namespace pbvs.Admin
{
    public class PbvsUser : IPrincipal
    {
        private readonly PbvsUserRepository _repository;
        private readonly Login _login;

        public Login Login
        {
            get { return _login; }
        }

        protected PbvsUser() : this(new Login()) { }

        public PbvsUser(Login login)
        {
            this._repository = new PbvsUserRepository();
            this._login = login;
        }

        public virtual IIdentity Identity { get; set; }

        public bool IsInRole(string role)
        {
            return _login.Roles.Any(r => r.Name == role);
        }
    }
}